//
//  NightViewController.m
//  UI外传_夜间模式
//
//  Created by dllo on 15/12/10.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "NightViewController.h"

@interface NightViewController ()

@end

@implementation NightViewController

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
    if (YES == [[NSUserDefaults standardUserDefaults] boolForKey:@"isNight"]) {
        self.view.backgroundColor = [UIColor grayColor];
        self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
    } else {
        self.view.backgroundColor = [UIColor whiteColor];
    }
    
    // 夜间模式消息通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nightAction) name:@"night" object:nil];
    
    // 日间模式消息通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayAction) name:@"day" object:nil];
    
}

- (void)dayAction
{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}

- (void)nightAction
{
    self.view.backgroundColor = [UIColor grayColor];
    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
